package com.zzl.test.aop;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * description: 测试AOP
 * @author 朱正磊
 * @date 2019-08-13 11:27:19
 */
public class MyTestAop {

    private ApplicationContext context =
            new ClassPathXmlApplicationContext("classpath:spring/applicationContext-aop.xml");

    @Test
    public void testJDKProxy() {
        // Spring IOC 容器中获取对象，测试Spring中JDK动态代理方式
        IUserDao userDao = (IUserDao) context.getBean("userDao");
        System.out.println(userDao.getClass());
        userDao.save();
    }

    @Test
    public void testCglibProxy() {
        // Spring IOC 容器中获取对象，测试Spring中Cglib动态代理方式
        OrderDao orderDao = (OrderDao) context.getBean("orderDao");
        System.out.println(orderDao.getClass());
        orderDao.save();
    }

}
